home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************
- *
- * $Source: /unixb/home/unixlib/source/unixlib37/src/clib/sys/h/RCS/stat,v $
- * $Date: 1996/10/30 21:58:59 $
- * $Revision: 1.5 $
- * $State: Rel $
- * $Author: unixlib $
- *
- * $Log: stat,v $
- * Revision 1.5 1996/10/30 21:58:59 unixlib
- * Massive changes made by Nick Burret and Peter Burwood.
- *
- * Revision 1.4 1996/09/16 21:23:51 unixlib
- * CL_0002 Nick Burret
- * Minor changes to file handling
- * Change most error numbers, and use in assembler sources (SJC)
- * Various minor bug fixes and compatability changes.
- *
- * Revision 1.3 1996/07/21 22:15:12 unixlib
- * CL_0001 Nick Burret
- * Improve memory handling. Remove C++ library incompatibilities.
- * Improve file stat routines.
- *
- * Revision 1.2 1996/05/06 09:01:33 unixlib
- * Updates to sources made by Nick Burrett, Peter Burwood and Simon Callan.
- * Saved for 3.7a release.
- *
- * Revision 1.1 1996/04/19 21:23:56 simon
- * Initial revision
- *
- ***************************************************************************/
-
- /* POSIX Standard 5.6: File Characteristics <sys/stat.h>. */
-
- #ifndef __SYS_STAT_H
- #define __SYS_STAT_H
-
- #ifndef __UNIXLIB_TYPES_H
- #include <unixlib/types.h>
- #endif
- #ifndef __TIME_H
- #include <time.h>
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- struct stat
- {
- __dev_t st_dev; /* Device containing the file. */
- __ino_t st_ino; /* File serial number. */
- __mode_t st_mode; /* File mode. */
- __nlink_t st_nlink; /* Link count. */
- __uid_t st_uid; /* User ID of the file's owner. */
- __gid_t st_gid; /* Group ID of the file's group. */
- __dev_t st_rdev; /* Device number, if device. */
- __off_t st_size; /* Size of file, in bytes. */
- time_t st_atime; /* Time of last access. */
- unsigned long int st_atime_usec;
- time_t st_mtime; /* Time of last modification. */
- unsigned long int st_mtime_usec;
- time_t st_ctime; /* Time of last status change. */
- unsigned long int st_ctime_usec;
- unsigned long int st_blksize; /* Optimal block size for I/O. */
- #define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */
- unsigned long int st_nblocks; /* Number of 512-byte blocks allocated. */
- };
-
- /* Bit masks. */
-
- /* Extract the file type code portion of a mode value. */
- #define S_IFMT 0770000
-
- /* File type code for a FIFO or pipe. */
- #define S_IFIFO 0010000
- #define S_IFPORT S_IFIFO
- /* File type code for a terminal type device file. */
- #define S_IFCHR 0020000
- /* File type code for a directory. */
- #define S_IFDIR 0040000
- /* File type code for a block-oriented device file (disk file). */
- #define S_IFBLK 0100000
- /* File type code for a regular file. */
- #define S_IFREG 0200000
- /* File type code for a symbolic link. */
- #define S_IFLNK 0400000
- /* This is the set-user-ID on execute bit. */
- #define S_ISUID 0004000
- /* This is the set-group-ID on execute bit. */
- #define S_ISGID 0002000
- /* Socket. */
- #define S_IFSOCK 0140000
-
- /* Protection bits. */
-
- /* Save swapped text after use. */
- #define S_ISVTX 01000
- /* Read by owner. */
- #define S_IREAD 0400
- /* Write by owner. */
- #define S_IWRITE 0200
- /* Execute by owner. */
- #define S_IEXEC 0100
-
- /* Execute (for ordinary files) or search (for directories)
- permission bit for the owner of the file. */
- #define S_IXUSR S_IEXEC
- /* Write permission bit for the owner of the file. */
- #define S_IWUSR S_IWRITE
- /* Read permission bit for the owner of the file. */
- #define S_IRUSR S_IREAD
-
- /* Read, write and execute by owner. */
- #define S_IRWXU (S_IREAD | S_SWRITE | S_IEXEC)
-
- #define S_IRGRP (S_IRUSR >> 3) /* Read by group. */
- #define S_IWGRP (S_IWUSR >> 3) /* Write by group. */
- #define S_IXGRP (S_IXUSR >> 3) /* Execute by group. */
- /* Read, write, and execute by group. */
- #define S_IRWXG (S_IRWXU >> 3)
-
- #define S_IROTH (S_IRGRP >> 3) /* Read by others. */
- #define S_IWOTH (S_IWGRP >> 3) /* Write by others. */
- #define S_IXOTH (S_IXGRP >> 3) /* Execute by others. */
- /* Read, write, and execute by others. */
- #define S_IRWXO (S_IRWXG >> 3)
-
-
-
- /* Return nonzero if the file is a directory. */
- #define S_ISDIR(x) ((x) & S_IFDIR)
- /* Return nonzero if the file is a terminal type device. */
- #define S_ISCHR(x) ((x) & S_IFCHR)
- /* Return nonzero if the file is a block special file (like a disk). */
- #define S_ISBLK(x) ((x) & S_IFBLK)
- /* Return nonzero if the file is a regular file. */
- #define S_ISREG(x) ((x) & S_IFREG)
- /* Return nonzero if the file is a FIFO file for pipe. */
- #define S_ISFIFO(x) ((x) & S_IFIFO)
- /* Return nonzero if the file is a symbolic link. */
- #define S_ISLNK(x) ((x) & S_IFLNK)
- /* Return nonzero if the file is a socket. */
- #define S_ISSOCK(x) ((x) & S_IFSOCK)
-
- extern int stat (const char *, struct stat *);
- extern int lstat (const char *, struct stat *);
- extern int fstat (int, struct stat *);
-
- /* Set file access permissions for file to mode. */
- extern int chmod (const char *file, __mode_t mode);
-
- /* Set file access permissions of the file fd is open on to mode. */
- extern int fchmod (int fd, __mode_t mode);
-
- /* Set the file creation mask of the current process to mask,
- return the old creation mask. */
- extern __mode_t umask (__mode_t mask);
-
- /* Create a new directory named path, with permission bits mode. */
- extern int mkdir (const char *path, __mode_t mode);
-
- #if 0
- /* Create a device file named path, with permission and special bits mode
- and device number dev. */
- extern int mknod (const char *path, __mode_t mode, __dev_t dev);
-
- /* Create a new FIFO named path, with permission bits mode. */
- extern int mkfifo (const char *path, __mode_t mode);
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif
-